﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fis.Service.Rules
{
    public class VersionViewProvider : Agile.Engine.View.ProxyViewProvider
    {
        public override System.Collections.Hashtable InitializeViewModel(System.Collections.Hashtable args)
        {
            var model = args ?? new System.Collections.Hashtable();
            model["Action"] = "get";

            var exec = InvokeService(model);
            model["data"] = Agile.Engine.Utils.ZipUtils.UnZipDataTable(ServiceProcess.Result["data"].ToString());

            return model;
        }

        public override bool ExecuteUpdate(System.Collections.Hashtable viewModel)
        {
            viewModel["data"] = Agile.Engine.Utils.ZipUtils.ZipDataTable(viewModel["data"] as System.Data.DataTable);

            var exec = InvokeService(viewModel);
            viewModel["data"] = Agile.Engine.Utils.ZipUtils.UnZipDataTable(ServiceProcess.Result["data"].ToString());

            View.Message = ServiceProcess.Message;

            return exec;
        }
    }
}
